include(tools/cmake/cortex-m4f.cmake)

# 生成 compile_commands.json，可配合 clangd 实现精准的代码关联与跳转；
SET(CMAKE_EXPORT_COMPILE_COMMANDS True)

# 彩色日志输出；
SET(CMAKE_COLOR_DIAGNOSTICS True)

cmake_minimum_required(VERSION 3.20 FATAL_ERROR)

project(notion
    VERSION 1.0
    DESCRIPTION "notion project"
    LANGUAGES C CXX ASM
)

set(PROJECT_PATH ${CMAKE_CURRENT_LIST_DIR})


if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/.config")
    execute_process(COMMAND
        python config.py ${CMAKE_BINARY_DIR}/config .config
        WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
    )

    file(WRITE config.h ${ab})
    message(STATUS ${ab})
else()
    message(WARNING ".config file not exist,start menuconfig")
    execute_process(COMMAND menuconfig
        ECHO_OUTPUT_VARIABLE
        WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
    )
endif()

include_directories(${CMAKE_BINARY_DIR})

include(${CMAKE_BINARY_DIR}/config.cmake)

add_subdirectory(target)

if($<STREQUAL:1,1>)
    message("build type is debug")
endif()